home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / skipandgouls.swf / scripts / __Packages / SecretCodeInterface.as < prev   
Text File  |  2007-10-01  |  2KB  |  87 lines

  1. class SecretCodeInterface extends sarbakan.visual.element.DynamicElement
  2. {
  3.    static var SECRET_CODES = {RANDOM_WAFFLES:"sun",BONUS_LEVEL:"pow",SYRUP_WATER:"find",RESET:"reset"};
  4.    function SecretCodeInterface(l_mc)
  5.    {
  6.       super("secretCode");
  7.       this.setMC(l_mc);
  8.    }
  9.    function show()
  10.    {
  11.       this.setState("open");
  12.    }
  13.    function open()
  14.    {
  15.       if(this.stateFinished())
  16.       {
  17.          this.setState("idle");
  18.       }
  19.    }
  20.    function idle()
  21.    {
  22.       if(this.stateStarting())
  23.       {
  24.          this.initButtons();
  25.       }
  26.       if(Key.isDown(13))
  27.       {
  28.          this.onButtonValidate();
  29.       }
  30.    }
  31.    function good()
  32.    {
  33.       if(this.stateFinished())
  34.       {
  35.          this.setState("close");
  36.       }
  37.    }
  38.    function bad()
  39.    {
  40.       if(this.stateFinished())
  41.       {
  42.          this.setState("idle");
  43.       }
  44.    }
  45.    function close()
  46.    {
  47.       if(this.stateFinished())
  48.       {
  49.          this.disable();
  50.       }
  51.    }
  52.    function onButtonValidate()
  53.    {
  54.       _global.C.oPackaging.clickSound();
  55.       this.validateCode();
  56.    }
  57.    function onButtonBack()
  58.    {
  59.       _global.C.oPackaging.clickSound();
  60.       this.setState("close");
  61.    }
  62.    function initButtons()
  63.    {
  64.       this.mc.state.btValidate.onRelease = sarbakan.utils.Delegate.create(this,this.onButtonValidate);
  65.       this.mc.state.btBack.onRelease = sarbakan.utils.Delegate.create(this,this.onButtonBack);
  66.    }
  67.    function validateCode()
  68.    {
  69.       var _loc3_ = false;
  70.       for(var _loc4_ in SecretCodeInterface.SECRET_CODES)
  71.       {
  72.          if(this.mc.state.code.text.toLowerCase() == SecretCodeInterface.SECRET_CODES[_loc4_])
  73.          {
  74.             _global.C.unlockCode(_loc4_);
  75.             _loc3_ = true;
  76.             this.setState("good");
  77.             getURL("javascript:trackEvent(\'" + SecretCodeInterface.SECRET_CODES[_loc4_] + "\');","");
  78.             break;
  79.          }
  80.       }
  81.       if(!_loc3_)
  82.       {
  83.          this.setState("bad");
  84.       }
  85.    }
  86. }
  87.